(setq package-archives '(("gnu" . "http://mirrors.ustc.edu.cn/elpa/gnu/")
                         ("melpa" . "http://mirrors.ustc.edu.cn/elpa/melpa/")
                         ("melpa-stable" . "http://mirrors.ustc.edu.cn/elpa/melpa-stable/")
                         ("org" . "http://mirrors.ustc.edu.cn/elpa/org/")))
(global-linum-mode 1)
(setq linum-format "%d ")
(require 'modern-cpp-font-lock)
(require 'unicad)
(package-initialize) ;; You might already have this line
(modern-c++-font-lock-global-mode t)

(show-paren-mode 1)

;;-----------------------------------------
;;Coding config

(prefer-coding-system 'gb18030)
(prefer-coding-system 'utf-8)

;;-----------------------------------------
;;Markdown Support

(autoload 'markdown-mode "markdown-mode"
         "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

(autoload 'gfm-mode "markdown-mode"
        "Major mode for editing GitHub Flavored Markdown files" t)
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))

;;-------------------------------------------
;;Auto complete for C
;;-------------------------------------------
(require 'auto-complete-config)
(ac-config-default)

(require 'auto-complete-clang)
(setq ac-auto-start nil)
(setq ac-quick-help-delay 0.5)
(define-key ac-mode-map [(control tab)] 'auto-complete)

    (defun my-ac-config ()
    (setq ac-clang-flags (split-string "-I/usr/include -I/usr/local/include -I/usr/include/c++/4.6 -I/home/cc/Documents/trunk/tools/x86/cppunit/include -I/home/cc/Documents/trunk/tools/x86/TinyXML -I/home/cc/Documents/trunk/tools/x86/libpcap-1.2.1/build/include -I/home/cc/Documents/trunk/Utility/Header -I/home/cc/Documents/trunk/Comm/Header "))
    (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
    (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
    (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
    (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
    (add-hook 'css-mode-hook 'ac-css-mode-setup)
    (add-hook 'auto-complete-mode-hook 'ac-common-setup)
    (global-auto-complete-mode t))
    (defun my-ac-cc-mode-setup ()
    (setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))
    (add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
    (my-ac-config)


;;--------------------------------------------
;;Neo tree
;;--------------------------------------------
(require 'neotree)
(global-set-key [f5] 'neotree-toggle)

;;--------------------------------------------
;;Common config
;;--------------------------------------------
(display-time-mode 1)
(setq display-time-24hr-format t)
(setq display-time-day-and-date t)
(tool-bar-mode nil)
(blink-cursor-mode 0)

(setq
     backup-by-copying t ; 自动备份
     backup-directory-alist
     '(("." . "~/.em_backup")) ; 自动备份在目录"~/.em_backup"下
     delete-old-versions t ; 自动删除旧的备份文件
     kept-new-versions 3 ; 保留最近的3个备份文件
     kept-old-versions 1 ; 保留最早的1个备份文件
     version-control t) ; 多次备份


(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(inhibit-startup-screen t)
 '(package-selected-packages
   '(neotree yasnippet auto-complete-clang auto-complete-c-headers auto-complete pandoc markdown-mode+ unicad modern-cpp-font-lock use-package)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "Cascadia Code PL" :foundry "SAJA" :slant normal :weight normal :height 120 :width normal)))))
